package mo.leetcode_top;

public class L26 {

    public int removeDuplicates(int[] nums) {
        if (nums.length <= 1) {
            return nums.length;
        }
        int index = 0;
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] > nums[index]) {
                index++;
                nums[index] = nums[i];
            }
        }
        return index+1;
    }

    public static void main(String[] args) {
        L26 test = new L26();
        System.out.println(test.removeDuplicates(new int[]{1, 1, 2}));
    }
}
